#include <iostream>

class Solution
{
public:
    int main()
    {
        int classTime, arrangedTime;
        int mostSadDay = 0;
        int sadness = 0;
        for (int i = 1; i <= 7; ++i)
        {
            std::cin >> classTime >> arrangedTime;
            int totalTime = classTime + arrangedTime;
            if (totalTime > 8)
            {
                if (totalTime > sadness)
                {
                    sadness = totalTime;
                    mostSadDay = i;
                }
            }
        }
        std::cout << mostSadDay;
        return 0;
    }
};

#ifndef __LOCAL_TEST__
int main()
{
    return Solution().main();
}
#endif